package com.bilgeadam.swing.program;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;

/**
 *
 * @author Bora SAYINER
 * @since Dec 13, 2014 1:23:01 PM
 * @version 1.0
 */
public class CompositePanels {

	public static void main(String[] args) {
		JFrame frmMain = new JFrame();
		frmMain.setTitle("Border Layout");
		frmMain.setSize(800, 600);
		frmMain.setLocationRelativeTo(null);
		frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		{
			{
				JButton btnNorth = new JButton("North Button");
				frmMain.add(btnNorth, BorderLayout.NORTH);
			}
			{
				JButton btnEast = new JButton("East Button");
				frmMain.add(btnEast, BorderLayout.EAST);
			}
			{
				JButton btnWest = new JButton("West Button");
				frmMain.add(btnWest, BorderLayout.WEST);
			}
			{
				JPanel pnlCenter = new JPanel();
				pnlCenter.setBorder(BorderFactory
						.createTitledBorder("Swing Components"));
				{
					{
						JTextField txtFirstName = new JTextField(20);
						txtFirstName.setText("Adınız...");
						txtFirstName.setEditable(false);
						System.out.println(txtFirstName.getText());
						pnlCenter.add(txtFirstName);
					}
					{
						JTextArea txtAddress = new JTextArea(10, 20);
						txtAddress.setLineWrap(true);
						JScrollPane jScrollPane = new JScrollPane(txtAddress);
						pnlCenter.add(jScrollPane);
					}
					{
						JLabel lblFirstName = new JLabel("Adınız:");
						pnlCenter.add(lblFirstName);
					}
					{
						JLabel lblHomer = new JLabel(new ImageIcon("homer.jpg"));
						lblHomer.setBorder(BorderFactory
								.createLineBorder(Color.BLUE));
						// pnlCenter.add(lblHomer);
					}
					{
						JCheckBox chkKabulMu = new JCheckBox(
								"Kabul ediyor musun?");
						chkKabulMu.setSelected(true);
						pnlCenter.add(chkKabulMu);
					}
					{
						JPanel pnlCinsiyet = new JPanel();
						pnlCinsiyet.setBorder(BorderFactory
								.createTitledBorder("Cinsiyet"));
						{
							ButtonGroup buttonGroup = new ButtonGroup();

							JRadioButton btnBay = new JRadioButton("Bay");
							JRadioButton btnBayan = new JRadioButton("Bayan");
							buttonGroup.add(btnBay);
							buttonGroup.add(btnBayan);

							btnBay.setSelected(true);

							pnlCinsiyet.add(btnBay);
							pnlCinsiyet.add(btnBayan);
						}
						pnlCenter.add(pnlCinsiyet);
					}
					{
						JComboBox<String> sehirler = new JComboBox<String>();
						sehirler.addItem("İstanbul");
						sehirler.addItem("Ankara");
						sehirler.addItem("Trabzon");
						pnlCenter.add(sehirler);
					}
					{
						JMenuBar menuBar = new JMenuBar();
						{
							{
								JMenu menu = new JMenu("File");
								{
									{
										JMenu jMenu = new JMenu("Test-1");
										{
											{
												JMenuItem item = new JMenuItem(
														"Test-2");
												jMenu.add(item);
											}
										}
										menu.add(jMenu);
									}
									{
										JMenuItem menuItem = new JMenuItem(
												"Open");
										menu.add(menuItem);
									}
									{
										JMenuItem menuItem = new JMenuItem(
												"Save");
										menu.add(menuItem);
									}
									{
										menu.addSeparator();
									}
									{
										JMenuItem menuItem = new JMenuItem(
												"Close");
										menuItem.setEnabled(false);
										menu.add(menuItem);
									}

								}
								menuBar.add(menu);
							}
						}
						frmMain.setJMenuBar(menuBar);
						{
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
							pnlCenter.add(WidgetFactory.createButton("test"));
						}
					}
				}
				frmMain.add(pnlCenter, BorderLayout.CENTER);
			}
			{
				JPanel pnlSouth = new JPanel();
				pnlSouth.setBorder(new LineBorder(Color.RED));
				pnlSouth.setBackground(Color.BLUE);
				{
					for (int i = 0; i < 5; i++) {
						JButton button = new JButton();
						button.setText(String.format(
								"<html><i>%s. Button</i></html>", i + 1));
						button.setBackground(Color.YELLOW);
						button.setForeground(Color.BLUE);
						button.setFont(new Font("serif", Font.BOLD, 14));
						button.setToolTipText("Fenerbahçe");
						if (i % 2 != 0) {
							button.setEnabled(false);
						}
						pnlSouth.add(button);
					}
				}
				frmMain.add(pnlSouth, BorderLayout.SOUTH);
			}
		}
		frmMain.setVisible(true);
	}

}
